<?php 
	global $SSO, $Security, $AppID, $User, $DB;
	//Check to see if there is a valid session 
	$SessionInfo = $SSO->isValidSession("index.php?action=login", $SSO->getSessionInformation());	
	
	//Check to see if the user has rights to be on LWAdmin
	$PageRights = array('ADMIN', 'USERADMIN');
	$Security->ValidateUser($SessionInfo['username'], $AppID, $PageRights, 1);

	$validator = new FormValidation();
	if(isset($_POST['username']) && !isset($_POST['btnYes']))
	{
		$validator->validateForm('fdf/Admin_Users_frmUserInfo.xml');
	}
	elseif(!isset($_POST['username']))
	{
		print "<span class='T1'>User Error: Form Not Posted by Previous Step</span><br>";
		print "<a href='index.php?action=users' class='LWAdminLink'>Back to the Users Page...</a></td><td width='33%'>&nbsp;</td></tr></table></td></tr></table>";
		exit();
	}
	if(isset($_POST['btnYes']))
	{
		$db_string = $DB->compile_db_insert_string( 
		array (
			'Username'		=> $_POST['username'],
			'FirstName'		=> $_POST['txtFirstName'],
			'MiddleName'   		=> $_POST['txtMiddleName'],
			'LastName'    		=> $_POST['txtLastName'],
			'PasswordTemp'  		=> str_shuffle($_POST['txtLastName'] . $_POST['txtFirstName']),
			'Email'		=> $_POST['txtEmail'],
			'HomePhone'		=> $_POST['txtHomePhone'],
			'WorkPhone'   		=> $_POST['txtWorkPhone'],
			'Address1'    		=> $_POST['txtAddress1'],
			'Address2'    		=> $_POST['txtAddress2'],
			'Zip'		=> $_POST['txtZip'],
			'City'		=> $_POST['txtCity'],
			'State'   		=> $_POST['txtState'])
			);
		
		//insert the session into the sessions table
		$DB->query("INSERT INTO users (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")");
		
		header("Location: index.php?action=users");
	}
?>


<form action="index.php?action=users_new&amp;step=3" method="post" name="frmConfirmation">
<?php 
	foreach($_POST as $field => $value)
	{
		print '<input type="hidden" name="' . $field . '" value="' . $value . '">';
	}





?>
<table style="border-spacing:0px;padding:5px;" border="0" align="center">
	<tr>
		<td><br>
		</td>
	</tr>
	<tr>
		<td align="center">
			<span class="T1">Are you sure you would like to add user <b><?php if(isset($_POST['username'])){print $_POST['username'];}?></b>?</span>
		</td>
	</tr>
	<tr>
		<td><br>
		</td>
	</tr>
	<tr>
		<td align="center">
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td align="center">
						<input name="btnYes" type="submit" value="Yes" class="LWAdminButton"> 
					</td>
					<td>&nbsp;&nbsp;&nbsp;
					</td>
					<td align="center">
						<input name="btnNo" type="button" value="No" class="LWAdminButton" onClick="location.href='index.php?action=users'"> 
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td><br>
		</td>
	</tr>
</table> 

			</form>

